home *** CD-ROM | disk | FTP | other *** search
- INCLUDE AINCLUDE:IncDirs.i *sets all includedirs, needed for my ASM
- INCLUDE FAST/xpkLibFAST.i
- include "xpk/xpk.i"
- include "xpk/xpksub.i"
- INCLUDE "exec/memory.i"
-
- INCLUDE FAST/compress.a
- INCLUDE FAST/compress2.a
- INCLUDE FAST/decompress.a
-
- ; XREF compress_fast
- ; XREF compress_slow
- ; XREF decompress
-
- PACKMEM_FAST equ $10000
- PACKMEM_SLOW equ $44000
-
- UNPACKMEM equ 0
-
- _XpksPackChunk:
- movem.l a0-a6/d1,-(a7)
- move.l a6,a5 ; lib base
- move.l a0,a4 ; xparams
-
- move.l xsp_Mode(a4),d1
-
- move.l #PACKMEM_FAST,d0
- lea.l compress_fast(pc),a3
-
- cmp.l #80,d1
- bcs.s IsFast
- move.l #PACKMEM_SLOW,d0
- lea.l compress_slow(pc),a3
- IsFast:
- tst.l xsp_Sub(a4) ;Is there some memory allocated?
- beq.s AllocPackMem
- cmp.l xsp_Sub+4(a4),d0 ; Is the size right?
- beq.s packMemOK
-
- bsr.s _XpksPackFree ; Free currently allocated memory.
- AllocPackMem:
- move.l d0,xsp_Sub+4(a4)
- move.l #MEMF_PUBLIC,d1
- move.l 4.W,a6
- JSR _LVOAllocMem(A6)
- move.l d0,xsp_Sub(a4)
- bne.s packMemOK
- move.l #XPKERR_NOMEM,d0
- bra.s endPackChunk
-
- packMemOK:
- move.l xsp_InBuf(a4),a0 ;a0:=InBuf
- move.l xsp_OutBuf(a4),a1 ;a1:=OutBuf
- move.l xsp_Sub(a4),a2 ;a2:=Hash
- move.l xsp_InLen(a4),d0 ;d0:=InLen
- moveq.l #90,d1
- jsr (a3) ; call the compressor.
- tst.l d0
- bne.s Nooverrun
- moveq.l #XPKERR_EXPANSION,d0
- bra.s endPackChunk
- Nooverrun:
- move.l d0,xsp_OutLen(a4) ;Fill in Final output length XpkSubParams
- moveq #XPKERR_OK,d0
- endPackChunk:
- movem.l (sp)+,a0-a6/d1
- rts
-
- _XpksPackFree: movem.l a0-a2/a6/d0-d1,-(a7)
- move.l xsp_Sub(a0),a1
- beq.s packFreeEnd
- clr.l xsp_Sub(a0)
- move.l xsp_Sub+4(a0),d0 ; currently allocated amount.
- clr.l xsp_Sub+4(a0)
- move.l 4.W,a6
- JSR _LVOFreeMem(A6)
- packFreeEnd: movem.l (a7)+,a0-a2/a6/d0-d1
- moveq #XPKERR_OK,d0
- rts
-
- _XpksUnpackChunk:
- move.l a1,-(sp)
- move.l xsp_OutBuf(a0),a1
- move.l xsp_InLen(a0),d0
- move.l xsp_InBuf(a0),a0
-
- bsr decompress
- move.l (sp)+,a1
- moveq.l #XPKERR_OK,d0
- rts
-
-
- _XpksPackerInfo:
- move.l a0,d0
- lea FastInfo(pc),a0
- exg a0,d0
- rts
-
-
- ; --- Static Data --------
- FastInfo:
- dc.w 1 ;xi_XpkInfoVersion:Version number of this structure
- dc.w VERSION ;xi_LibVersion : The version of this sublibrary
- dc.w 2 ;xi_MasterVersion: The required master lib version
- dc.w 0 ;xi_ModesVersion : Longword align
- dc.l FastName ;xi_Name : Brief name of the packer
- dc.l LongName ;xi_LongName : Full name of the packer
- dc.l Description ;xi_Description : One line description of packer
- dc.b 'FAST' ;xi_ID : ID the packer goes by (XPK format)
- ;xi_Flags : Defined below
- dc.l XPKIF_PK_CHUNK|XPKIF_UP_CHUNK|XPKIF_MODES
- dc.l $7FFFFFFF ;xi_MaxPkInChunk : Max input chunk size for packing
- dc.l 0 ;xi_MinPkInChunk : Min input chunk size for packing
- dc.l $10000 ;xi_DefPkInChunk : Default packing chunk size
- dc.l PackMsg ;xi_PackMsg : Packing message, present tense
- dc.l UnpackMsg ;xi_UnpackMsg : Unpacking message, present tense
- dc.l PackedMsg ;xi_PackedMsg : Packing message, past tense
- dc.l UnpackedMsg ;xi_UnpackedMsg : Unpacking message, past tense
- dc.w 50 ;xi_DefMode : Default mode number
- dc.w 0 ;xi_Pad : for future use
- dc.l Modes ;xi_Modes : Array of compression modes
- dc.l 0,0,0,0,0,0 ;xi_Reserved,6*4 : Future expansion - set to zero
-
- FastName: dc.b 'fasTcinator',0
- LongName: dc.b 'FAST alias WOOP or LZRW++',0
- Description: dc.b 'LZ77-family, windowsize: 4095, no quotecount, 2 streams',0
- PackMsg: dc.b 'tieing',0
- PackedMsg: dc.b 'compressed',0
- UnpackMsg: dc.b 'untieing',0
- UnpackedMsg: dc.b 'decompressed',0
- EVEN
-
- Modes:
- dc.l Crawling ;xm_Next : Chain to next descriptor for ModeDesc list
- dc.l 79 ;xm_Upto : Maximum efficiency handled by this mode.
- ;xm_Flags : Defined below
- dc.l XPKMF_A3000SPEED
- dc.l PACKMEM_FAST ;xm_PackMemory : Extra memory required during packing
- dc.l UNPACKMEM ;xm_UnpackMemory : Extra memory during unpacking
- dc.l 428 ;xm_PackSpeed : Approx packing speed in K per second
- dc.l 1055 ;xm_UnpackSpeed : Approx unpacking speed in K per second
- dc.w 327 ;xm_Ratio : CF in 0.1% for AmigaVision executable
- dc.w 0 ;xm_ChunkSize : Desired chunk size in K (!!) for this mode
- dc.b 'speedy',0,0,0,0 ;xm_Description,10:8 character mode description
-
- Crawling:
- dc.l 0 ;xm_Next : Chain to next descriptor for ModeDesc list
- dc.l 100 ;xm_Upto : Maximum efficiency handled by this mode.
- ;xm_Flags : Defined below
- dc.l XPKMF_A3000SPEED
- dc.l PACKMEM_SLOW ;xm_PackMemory : Extra memory required during packing
- dc.l UNPACKMEM ;xm_UnpackMemory : Extra memory during unpacking
- dc.l 70 ;xm_PackSpeed : Approx packing speed in K per second
- dc.l 1096 ;xm_UnpackSpeed : Approx unpacking speed in K per second
- dc.w 393 ;xm_Ratio : CF in 0.1% for AmigaVision executable
- dc.w 0 ;xm_ChunkSize : Desired chunk size in K (!!) for this mode
- dc.b 'crawling',0,0 ;xm_Description,10:8 character mode description
- END
-